package com.syni.mdd.yhd.common.all.config.pay.alipay;

import com.syni.mdd.sjb.common.component.utils.common.spring.ApplicationContextHolder;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Profile;

/**
 * @className AlipayConfig
 * @description TOO
 * @Author cfx
 * @DATE 2020/2/6 16:58
 * @VERSION 1.0
 **/
@Configuration
@DependsOn("applicationContextHolder")
@Log4j2
public class AlipayConfigRun {

    @Value("${DEV_BACK_URL}")
    private String DEV_BACK_URL;

    //旧的支付环境
    private final static String appid_old = "2019070865738911";
    private final static String privateKey_old = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDQ6WDqMhW3vSommCAxQNueXOLLVIHPzb8T0RPpUxyUB7aeal3fcsaiQf343QRFhCYTQfF1kw6AiFaKA8Se9VPEE0RuN89IkeYg89g3JQEtZm7iPZfaf0NysP6A+wp6xCk6z7zRz1TLmz5BIS2nWMVq5m7bANp0dGbZwc3TRuxSmw6t1fghZsMw4mrRzsg/CZ+iRiat7BwKqz7XBiKkf7bdPUrdiU7G9m842751TP1hTNg0Z4wJBHwqNNTLxbNsGM7xlIhXcE1xk1b9N3JYdMBgauWcQnMVySosdWhQeFFGo+NhvDE+1UPBQUASF86bDubFjjHyuUQ7RDVyw6kgDucRAgMBAAECggEAeetpYuP95rAf9EwdpYDrap1cwjs8UvEJDWCcVTPq3r0tp3/97tTF9ZW7yUv7HTLFIcH/T5WWBg8LKhqO2hHkY+62pfguIXT8L8j/KxeOe1dnaON3Rs20qC+BJ/baI9FtGmR4Fp4AJ58fEtVxFlPpSrzWfzsdQo9YIsdG/oFKk93Y839iiGaE+PUoc4Y0Fbc8hzV0w1iLDad80TweCTWUrEleMJqZNi+MibB3T7h/ipP2lWOPvP262WXp3llfBxxJ5l9022a6O2qYQLtQw3QqMY1bvQrChBYPw9rB0r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ek73zYIItcOis+mophE1hyzn6VX6/zENm1a+q2NwMK+uYWafUqBxpunA6Y5J/6vhmNlLpXDKIfpqK69aTRoaYi7pFdqIWa5Z5DmKA5n84Evwx69+XW0YB50e/wmy2jqqKCuMOof8InZ3Lpz2RrpnC5qiyFl56ekiDCgKLWIgsRud46uuiW15R2zQTvyi1wvYnWy2lw7RVIV1LbtX2LhiiVLW8cVorsH6rucBsBASy+6ZxNlnbSnDKq7fUObMuuwIDAQAB";
    private final static String serverUrl_old = "https://openapi.alipay.com/gateway.do";
    private final static String companyPayNo_old = "2088031456998454";
    private final static String callBackUrl_old =  "/MDD_API/DSP_API/aliPay/AppAliPayNotify";
    private final static String callBackUrl_old_pro = "https://w.syni.com/DSP_API/aliPay/AppAliPayNotify";

    //支付配置
    private final static String appid = "2019110868961437";
    private final static String privateKey = "MIIEugIBADANBgkqhkiG9w0BAQEFAASCBKQwggSgAgEAAoIBAQCINCDVklKWISNyd6iKDHrgMgf2ZLcb7BiUAVfkdqLNICTQBpw9NvZn4x7kkCzJLplVLUDGJg36NPZRnNUv5CkzjbMfOw313Q/SWYUXfbgBYeCWnYFPgpaZf8DOoRuanE+7s6YAITU4TjUP6nY7Jd5mVsWx1XnBQ+kq1DcWdYLUD7z+KIo5XmsksdKWHPxnJ7KgDFDIVjvKwkFmQw6pbAj/koc8++uuWGGrs+sbsGBglh/ZmUV1tfPa4PJieWvK1QZJTIWzrnnXTnT7S+ye4ee3q1ubeOqg1NXDQiNLFUk0NG30q/3u6IpzsVvjQWCnSdWGDavLzCfxiGRNiQZQvakRAgMBAAECggEAQoxdwpw0t9/HJwWqFpFUdDhdxZieEwl/VMl3PUxt7RWYhv/D1PEG4emJzZlYGJApIQH0VRyA1dCMzYF4dGbhbqv8afT7tDZnpZpRuhGWFy7QgibA6K1gke1msk7rYtae6pIzOHsBOtqTeIxRakLtcElTXLl2POTGh0ObCuEtpBi5r/C9NOmCY9PcNDDj0nBuo6GvWbeKBYMlBDQNbLIqA+iulKLyV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/zRpadNyYrGQcQaXRq8AKT1njJOG0tN/LIAm2W7F88YBflsy2TeEjBSBZWLgALei1HVgVdOFfDWpF2bUpavTb2m11UusbKH7hIMcSA4WH6zknzq34TSbGEP2lC1dFkct/bOHP+qtI2SVTFQJIIhkTLHvZC2n7wFfwzm6tEDXWjyfmGUGH0vCNBAkfuKvK9BJMWG/XCyeWVsLm23OFaBX0dyhyV26AzUm+1iYbqROS/hbnWjLQ79t82effHy9gmDAfO2+Qjpm16JYIjnBpKiEHRzz8IRTWfzWhPzIJYc+N07HM7mJTjTFznP67r6d2T+SXO8rdTCTTkwIDAQAB";
    private final static String serverUrl = "https://openapi.alipay.com/gateway.do";
    private final static String companyPayNo = "2088631775398616";
    private final static String callBackUrl_dev = "/MDD_API/DSP_API/aliPay/AppAliPayNotify";
    //作为组件支撑的统一回调地址
    private final static String appPayServiceCallBackUrl_dev = "/MDD_API/DSP_API/aliPay/appPayServicePayNotify";
    //生产环境
    private final static String callBackUrl_pro = "https://midongdong.com/DSP_API/aliPay/AppAliPayNotify";
    private final static String appPayServiceCallBackUrl_pro = "https://w.syni.com/DSP_API/aliPay/appPayServicePayNotify";

    /*//生产环境
    private final static String appid_pro = "2019110868961437";
    private final static String privateKey_pro = "MIIEugIBADANBgkqhkiG9w0BAQEFAASCBKQwggSgAgEAAoIBAQCINCDVklKWISNyd6iKDHrgMgf2ZLcb7BiUAVfkdqLNICTQBpw9NvZn4x7kkCzJLplVLUDGJg36NPZRnNUv5CkzjbMfOw313Q/SWYUXfbgBYeCWnYFPgpaZf8DOoRuanE+7s6YAITU4TjUP6nY7Jd5mVsWx1XnBQ+kq1DcWdYLUD7z+KIo5XmsksdKWHPxnJ7KgDFDIVjvKwkFmQw6pbAj/koc8++uuWGGrs+sbsGBglh/ZmUV1tfPa4PJieWvK1QZJTIWzrnnXTnT7S+ye4ee3q1ubeOqg1NXDQiNLFUk0NG30q/3u6IpzsVvjQWCnSdWGDavLzCfxiGRNiQZQvakRAgMBAAECggEAQo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oCNRVnSYxJRp01Db3RWJY2dxgUYrtUd0awCXh4Lm0P7LBsAt73A4T1AtcPc5M4TLLvugUaQLund2YsqzpWTJCsB0HgRFbOAIxCVWQYtqMHM6Kyf+H7SnVBZ4NPrQpIjcA04AEACi6inr3qD9O4=";
    private final static String publicKey_pro = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjGqbazqqG61/zRpadNyYrGQcQaXRq8AKT1njJOG0tN/LIAm2W7F88YBflsy2TeEjBSBZWLgALei1HVgVdOFfDWpF2bUpavTb2m11UusbKH7hIMcSA4WH6zknzq34TSbGEP2lC1dFkct/bOHP+qtI2SVTFQJIIhkTLHvZC2n7wFfwzm6tEDXWjyfmGUGH0vCNBAkfuKvK9BJMWG/XCyeWVsLm23OFaBX0dyhyV26AzUm+1iYbqROS/hbnWjLQ79t82effHy9gmDAfO2+Qjpm16JYIjnBpKiEHRzz8IRTWfzWhPzIJYc+N07HM7mJTjTFznP67r6d2T+SXO8rdTCTTkwIDAQAB";
    private final static String serverUrl_pro = "https://openapi.alipay.com/gateway.do";
    private final static String companyPayNo_pro = "2088631775398616";*/


    //小程序环境
    private final static String appid_min_dev = "2021001146626193";
    private final static String privateKey_min_dev = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCfxuX8Ta2EywupNINUyMjqYaoA1KWMd8eULT+5cHNCD772nkipkGsI2S1S4bK/ki+eUlldSI5vS3jGl1nR9A8IFBMZAAgky8WW5JsJ+nci5GijvvHkNH/q8LnjGgT7tu7FZGYi3S0Y9tfPIMv3pxPGz+wGyvrYElLg0R/BNWFOTkaH+pb04o3PIueH3fsS4rzkBD34RPMBUMuin2JC4xdfwh0KjfmmerH3I6v6NY8Lwn5PJErFN1vbXZYLEmryhP3L8xDCW+Ud2FeqZqT++Y7/PwBzrWGa8lLx5NLBErKo1aUK0JjE77PXE7Hd/pzj+b8NwB0HeE2/c1EYpC44ggIJAgMBAAECggEAXqWN+2Vw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eRsk+MTSHzCXQf8HnreRM/cnNlgQHTB0c3b2/CPrgWsPTgeeye4pG1Zu9taYVp+9WCJG4oIKdgFivZHvF2zXMCPgZ8s3Yz2h1akKeSz7OOjc8incXJdowtvkg==";
    private final static String publicKey_min_dev = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjGqbazqqG61/zRpadNyYrGQcQaXRq8AKT1njJOG0tN/LIAm2W7F88YBflsy2TeEjBSBZWLgALei1HVgVdOFfDWpF2bUpavTb2m11UusbKH7hIMcSA4WH6zknzq34TSbGEP2lC1dFkct/bOHP+qtI2SVTFQJIIhkTLHvZC2n7wFfwzm6tEDXWjyfmGUGH0vCNBAkfuKvK9BJMWG/XCyeWVsLm23OFaBX0dyhyV26AzUm+1iYbqROS/hbnWjLQ79t82effHy9gmDAfO2+Qjpm16JYIjnBpKiEHRzz8IRTWfzWhPzIJYc+N07HM7mJTjTFznP67r6d2T+SXO8rdTCTTkwIDAQAB";
    private final static String min_aes_key = "sPxta8vcUyoy4jh/uqKqhw==";
    //private final static String min_companyPayNo = "2088631775398616";
    private final static String min_callBackUrl_dev = "/MDD_API/DSP_API/aliPay/AliMinAppPayNotify";
    private final static String min_callBackUrl_pro = "https://w.syni.com/DSP_API/aliPay/AliMinAppPayNotify";

    @Bean(name = "aliPayConfig")
    public AlipayConfig getAlipayConfigByPro(){
        AlipayConfig alipayConfig = new AlipayConfig();
        alipayConfig.setAppid(appid);
        alipayConfig.setPrivateKey(privateKey);
        alipayConfig.setPublicKey(publicKey);
        alipayConfig.setServerUrl(serverUrl);
        alipayConfig.setCompanyPayNo(companyPayNo);
        alipayConfig.setCallBackUrl(DEV_BACK_URL + callBackUrl_dev);
        alipayConfig.setMicroServiceCallBackUrl(DEV_BACK_URL + appPayServiceCallBackUrl_dev);
        if(ApplicationContextHolder.checkRunProfile(ApplicationContextHolder.RUN_PRO)){
            alipayConfig.setCallBackUrl(callBackUrl_pro);
            alipayConfig.setMicroServiceCallBackUrl(appPayServiceCallBackUrl_pro);
        }
        return alipayConfig;
    }

    @Bean(name = "oldAliPayConfig")
    public AlipayConfig getOldAliPayConfig(){
        AlipayConfig alipayConfig = new AlipayConfig();
        alipayConfig.setAppid(appid_old);
        alipayConfig.setPrivateKey(privateKey_old);
        alipayConfig.setPublicKey(publicKey_old);
        alipayConfig.setServerUrl(serverUrl_old);
        alipayConfig.setCompanyPayNo(companyPayNo_old);
        alipayConfig.setCallBackUrl(DEV_BACK_URL + callBackUrl_old);
        if(ApplicationContextHolder.checkRunProfile(ApplicationContextHolder.RUN_PRO)){
            alipayConfig.setCallBackUrl(callBackUrl_old_pro);
        }
        return alipayConfig;
    }

    @Bean(name = "aliMiniAppConfig")
    public AlipayConfig getMiniAppConfig(){
        AlipayConfig alipayConfig = new AlipayConfig();
        alipayConfig.setAppid(appid_min_dev);
        alipayConfig.setPrivateKey(privateKey_min_dev);
        alipayConfig.setPublicKey(publicKey_min_dev);
        alipayConfig.setServerUrl(serverUrl);
        alipayConfig.setCompanyPayNo(companyPayNo);
        alipayConfig.setCallBackUrl(DEV_BACK_URL + min_callBackUrl_dev);
        if(ApplicationContextHolder.checkRunProfile(ApplicationContextHolder.RUN_PRO)){
            alipayConfig.setCallBackUrl(min_callBackUrl_pro);
        }
        alipayConfig.setAesKey(min_aes_key);
        return alipayConfig;
    }
}
